package org.timemachine.tool;

import org.timemachine.tool.spi.ClassLoaderHelper;

public class ClassLoaderHelperImpl implements ClassLoaderHelper {

	public ClassLoader getLoader() {
		ClassLoader cLoader = Thread.currentThread().getContextClassLoader();
		return cLoader;
	}
	
    private Class<?> getSuperClassLoader(ClassLoader cLoader) {
		Class<?> clClazz = cLoader.getClass();
	    System.out.println("Classloader: " + clClazz.getCanonicalName());
	    while (clClazz != java.lang.ClassLoader.class) {
	    	clClazz = clClazz.getSuperclass();
	    }
	    return clClazz;
    }

	public Class<?> getLoaderClass() {
		return getSuperClassLoader(getLoader());
	}
	
}
